﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DotNetNinjaLibrary.Basics
{
	public struct Point : IEquatable<Point>
	{
		private int x;
		private int y;
		private int hashCode;

		public Point(int x, int y)
		{
			this.x = x;
			this.y = y;
			this.hashCode = x.GetHashCode() + 13 * y.GetHashCode();
		}

		public int X { get { return x; } }
		public int Y { get { return y; } }

		public bool Equals(Point other)
		{
			return this.X == other.X && this.Y == other.Y;
		}

		public static bool operator==(Point a, Point b)
		{
			return a.Equals(b);
		}

		public static bool operator !=(Point a, Point b)
		{
			return !a.Equals(b);
		}

		public override bool Equals(object obj)
		{
			return obj is Point && this.Equals((Point)obj);
		}

		public override int GetHashCode()
		{
			return this.hashCode;
		}

		public override string ToString()
		{
			return String.Format("({0}, {1})", X, Y);
		}
	}
}